# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=wiiuse
pkgver=0.15.5
pkgrel=2
pkgdesc="A library written in C that connects with several Nintendo Wii remotes"
arch=(loong64 x86_64)
url="https://github.com/wiiuse/wiiuse"
license=(GPL3)
depends=(
  bluez-libs
  glibc
)
provides=(libwiiuse.so)
makedepends=(cmake)
source=($url/archive/$pkgver/$pkgname-$pkgver.tar.gz)
sha512sums=('51a5abb8473b02a4537a73beb3f0012207294a828c332163ed2e99fa06e9905f590c7a0dc756a9182547c055c9b2218106e0a90dee7373fe33b8187c797cd3b8')
b2sums=('f92ca394d69580d9685bd1628f185f990c1f7fe80a29a0c662c4b197735c330ddaeea545a1bb41ced7500570f4c163bb3e0ae7f3a2814e24557c0c8121687fe2')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_LIBDIR=lib
    -D CMAKE_INSTALL_PREFIX=/usr
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/{{CHANGELOG,README}.mkd,RELEASE.md} -t "$pkgdir/usr/share/doc/$pkgname/"
}
